package com.zxshhy.controller;


import com.alibaba.fastjson.JSONObject;
import com.zxshhy.entity.Account;
import com.zxshhy.mapper.BusinessMapper;
import com.zxshhy.vo.ResultVo;
import lombok.extern.slf4j.Slf4j;
import org.assertj.core.util.Lists;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;


/**
 * @author zxs
 */
@RefreshScope
@RestController
@RequestMapping("/order")
@Slf4j
public class TestController {

    @Value("${zxshhy.seata.data-source-proxy-mode:XXXX}")
    private String trxMode;

    @Resource
    private BusinessMapper businessMapper;

    @PostMapping("/createOrder")
    public ResultVo createOrder(@RequestBody JSONObject jsonObject){
        log.info("收到下单请求参数:{},trxMode={}", jsonObject,trxMode);
        Account account1 = businessMapper.getByUserId(jsonObject.getString("userId"));
        Account account = businessMapper.selectByUserId(jsonObject.getString("userId"));
        List<Account> list = Lists.newArrayList(account1,account);
        return ResultVo.ok().put("account",list);
    }
    
}
